<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
    <head>
        <!-- Book generated using mdBook -->
        <meta charset="UTF-8">
        <title>part1_1_building - learning-gem5</title>
        <!-- Custom HTML head -->
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

        <link rel="icon" href="../favicon.svg">
        <link rel="shortcut icon" href="../favicon.png">
        <link rel="stylesheet" href="../css/variables.css">
        <link rel="stylesheet" href="../css/general.css">
        <link rel="stylesheet" href="../css/chrome.css">
        <link rel="stylesheet" href="../css/print.css" media="print">
        <!-- Fonts -->
        <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
        <link rel="stylesheet" href="../fonts/fonts.css">
        <!-- Highlight.js Stylesheets -->
        <link rel="stylesheet" href="../highlight.css">
        <link rel="stylesheet" href="../tomorrow-night.css">
        <link rel="stylesheet" href="../ayu-highlight.css">

        <!-- Custom theme stylesheets -->
    </head>
    <body>
        <!-- Provide site root to javascript -->
        <script type="text/javascript">
            var path_to_root = "../";
            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
        </script>

        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mdbook-theme');
                var sidebar = localStorage.getItem('mdbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
            if (theme === null || theme === undefined) { theme = default_theme; }
            var html = document.querySelector('html');
            html.classList.remove('no-js')
            html.classList.remove('light')
            html.classList.add(theme);
            html.classList.add('js');
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var html = document.querySelector('html');
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            html.classList.remove('sidebar-visible');
            html.classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <div class="sidebar-scrollbox">
                <ol class="chapter"><li class="chapter-item expanded affix "><a href="../part0_introduction.html">Learning gem-5</a></li><li class="chapter-item expanded "><a href="../part0_introduction.html"><strong aria-hidden="true">1.</strong> part0_introduction</a></li><li class="chapter-item expanded "><a href="../part1/part1_1_building.html" class="active"><strong aria-hidden="true">2.</strong> part1</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../part1/part1_1_building.html" class="active"><strong aria-hidden="true">2.1.</strong> part1_1_building</a></li><li class="chapter-item expanded "><a href="../part1/part1_2_simple_config.html"><strong aria-hidden="true">2.2.</strong> part1_2_simple_config</a></li><li class="chapter-item expanded "><a href="../part1/part1_3_cache_config.html"><strong aria-hidden="true">2.3.</strong> part1_3_cache_config</a></li><li class="chapter-item expanded "><a href="../part1/part1_4_gem5_stats.html"><strong aria-hidden="true">2.4.</strong> part1_4_gem5_stats</a></li><li class="chapter-item expanded "><a href="../part1/part1_5_gem5_example_configs.html"><strong aria-hidden="true">2.5.</strong> part1_5_gem5_example_configs</a></li><li class="chapter-item expanded "><a href="../part1/part1_6_extending_configs.html"><strong aria-hidden="true">2.6.</strong> part1_6_extending_configs</a></li></ol></li><li class="chapter-item expanded "><a href="../part2/part2_0_environment.html"><strong aria-hidden="true">3.</strong> part2</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../part2/part2_0_environment.html"><strong aria-hidden="true">3.1.</strong> part2_0_environment</a></li><li class="chapter-item expanded "><a href="../part2/part2_1_helloobject.html"><strong aria-hidden="true">3.2.</strong> part2_1_helloobject</a></li><li class="chapter-item expanded "><a href="../part2/part2_2_debugging.html"><strong aria-hidden="true">3.3.</strong> part2_2_debugging</a></li><li class="chapter-item expanded "><a href="../part2/part2_3_events.html"><strong aria-hidden="true">3.4.</strong> part2_3_events</a></li><li class="chapter-item expanded "><a href="../part2/part2_4_parameters.html"><strong aria-hidden="true">3.5.</strong> part2_4_parameters</a></li><li class="chapter-item expanded "><a href="../part2/part2_5_memoryobject.html"><strong aria-hidden="true">3.6.</strong> part2_5_memoryobject</a></li><li class="chapter-item expanded "><a href="../part2/part2_6_simplecache.html"><strong aria-hidden="true">3.7.</strong> part2_6_simplecache</a></li><li class="chapter-item expanded "><a href="../part2/part2_7_arm_power_modelling.html"><strong aria-hidden="true">3.8.</strong> part2_7_arm_power_modelling</a></li><li class="chapter-item expanded "><a href="../part2/part2_8_arm_dvfs_support.html"><strong aria-hidden="true">3.9.</strong> part2_8_arm_dvfs_support</a></li></ol></li><li class="chapter-item expanded "><a href="../part3/part3_00_MSIntro.html"><strong aria-hidden="true">4.</strong> part3</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="../part3/part3_00_MSIntro.html"><strong aria-hidden="true">4.1.</strong> part3_00_MSIntro</a></li><li class="chapter-item expanded "><a href="../part3/part3_01_cache-intro.html"><strong aria-hidden="true">4.2.</strong> part3_01_cache-intro</a></li><li class="chapter-item expanded "><a href="../part3/part3_02_cache-declarations.html"><strong aria-hidden="true">4.3.</strong> part3_02_cache-declarations</a></li><li class="chapter-item expanded "><a href="../part3/part3_03_cache-in-ports.html"><strong aria-hidden="true">4.4.</strong> part3_03_cache-in-ports</a></li><li class="chapter-item expanded "><a href="../part3/part3_04_cache_actions.html"><strong aria-hidden="true">4.5.</strong> part3_04_cache_actions</a></li><li class="chapter-item expanded "><a href="../part3/part3_05_cache_transitions.html"><strong aria-hidden="true">4.6.</strong> part3_05_cache_transitions</a></li><li class="chapter-item expanded "><a href="../part3/part3_06_directory.html"><strong aria-hidden="true">4.7.</strong> part3_06_directory</a></li><li class="chapter-item expanded "><a href="../part3/part3_07_MSIbuilding.html"><strong aria-hidden="true">4.8.</strong> part3_07_MSIbuilding</a></li><li class="chapter-item expanded "><a href="../part3/part3_08_configuration.html"><strong aria-hidden="true">4.9.</strong> part3_08_configuration</a></li><li class="chapter-item expanded "><a href="../part3/part3_09_running.html"><strong aria-hidden="true">4.10.</strong> part3_09_running</a></li><li class="chapter-item expanded "><a href="../part3/part3_10_MSIdebugging.html"><strong aria-hidden="true">4.11.</strong> part3_10_MSIdebugging</a></li><li class="chapter-item expanded "><a href="../part3/part3_11_simple-MI_example.html"><strong aria-hidden="true">4.12.</strong> part3_11_simple-MI_example</a></li></ol></li><li class="chapter-item expanded "><a href="../part4_gem5_101.html"><strong aria-hidden="true">5.</strong> part4_gem5_101</a></li><li class="chapter-item expanded "><a href="../http://doxygen.gem5.org/develop/index.html"><strong aria-hidden="true">6.</strong> part4_gem5_102</a></li></ol>
            </div>
            <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                <div id="menu-bar-hover-placeholder"></div>
                <div id="menu-bar" class="menu-bar sticky bordered">
                    <div class="left-buttons">
                        <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                            <i class="fa fa-bars"></i>
                        </button>
                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                            <i class="fa fa-paint-brush"></i>
                        </button>
                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                            <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                        </ul>
                        <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>

                    <h1 class="menu-title">learning-gem5</h1>

                    <div class="right-buttons">
                        <a href="../print.html" title="Print this book" aria-label="Print this book">
                            <i id="print-button" class="fa fa-print"></i>
                        </a>
                    </div>
                </div>

                <div id="search-wrapper" class="hidden">
                    <form id="searchbar-outer" class="searchbar-outer">
                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
                    </form>
                    <div id="searchresults-outer" class="searchresults-outer hidden">
                        <div id="searchresults-header" class="searchresults-header"></div>
                        <ul id="searchresults">
                        </ul>
                    </div>
                </div>
                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <hr />
<h2>layout: documentation
title: Building gem5
doc: Learning gem5
parent: part1
permalink: /documentation/learning_gem5/part1/building/
author: Jason Lowe-Power</h2>
<h1 id="构建-gem5"><a class="header" href="#构建-gem5">构建 gem5</a></h1>
<p>本章详细介绍了如何搭建 gem5 开发环境和构建 gem5。</p>
<h2 id="gem5的要求"><a class="header" href="#gem5的要求">gem5的要求</a></h2>
<p>有关更多详细信息，请参阅<a href="http://www.gem5.org/documentation/general_docs/building#dependencies">gem5 要求</a>。</p>
<p>在 Ubuntu 上，您可以使用以下命令安装所有必需的依赖项。要求详述如下：</p>
<pre><code class="language-bash">sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python3-dev python3
</code></pre>
<ol>
<li>
<ul>
<li>
<p>git（<a href="https://git-scm.com/">git</a>）：</p>
<p>gem5 项目使用<a href="https://git-scm.com/">Git</a>进行版本控制。<a href="https://git-scm.com/">Git</a>是一个分布式版本控制系统。可以通过以下链接找到有关<a href="https://git-scm.com/">Git 的</a>更多信息 。Git 应该默认安装在大多数平台上。要自行在 Ubuntu 中安装 Git，请使用<code>sudo apt install git </code></p>
</li>
</ul>
</li>
<li>
<ul>
<li>
<p>gcc 7+</p>
<p>您可能需要使用环境变量来指向 gcc 的非默认版本。在 Ubuntu 上，您可以使用以下命令安装开发环境<code>sudo apt install build-essential </code></p>
</li>
</ul>
<p><strong>我们支持 GCC 版本 &gt;=7，最高 GCC 10</strong></p>
</li>
<li>
<ul>
<li>
<p><a href="http://www.scons.org/">SCons 3.0+</a></p>
<p>gem5 使用 SCons 作为其构建环境。SCons 就像类固醇一样，在构建过程的各个方面都使用 Python 脚本。这允许一个非常灵活（如果慢）的构建系统。要在 Ubuntu 上使用 SCons<code>sudo apt install scons </code></p>
</li>
</ul>
</li>
<li>
<ul>
<li>
<p>Python 3.6+</p>
<p>gem5 依赖于 Python 开发库。要在 Ubuntu 上安装这些，请使用<code>sudo apt install python3-dev </code></p>
</li>
</ul>
</li>
<li>
<ul>
<li>
<p><a href="https://developers.google.com/protocol-buffers/">protobuf</a> 2.1+（<strong>可选</strong>）</p>
<p>“protobuf是一种语言独立、平台独立的可扩展机制，用于序列化结构化数据。” 在 gem5 中，<a href="https://developers.google.com/protocol-buffers/">protobuf</a> 库用于跟踪生成和回放。 <a href="https://developers.google.com/protocol-buffers/">protobuf</a>不是必需的包，除非您计划将其用于跟踪生成和回放。<code>sudo apt install libprotobuf-dev protobuf-compiler libgoogle-perftools-dev </code></p>
</li>
</ul>
</li>
<li>
<ul>
<li>
<p><a href="https://www.boost.org/">boost</a>（<strong>可选</strong>）</p>
<p>boost 库是一组通用的 C++ 库。如果您希望使用 SystemC 实现，它是一个必要的依赖项。<code>sudo apt install libboost-all-dev </code></p>
</li>
</ul>
</li>
</ol>
<h2 id="获取代码"><a class="header" href="#获取代码">获取代码</a></h2>
<p>将目录更改为要下载 gem5 源代码的位置。然后，要克隆存储库，请使用该<code>git clone</code>命令。</p>
<pre><code class="language-bash">git clone https://gitee.com/mirrors/gem5
</code></pre>
<p>您现在可以进入<code>gem5</code>，里面包含所有 gem5 代码。</p>
<h2 id="构建你的第一个-gem5"><a class="header" href="#构建你的第一个-gem5">构建你的第一个 gem5</a></h2>
<p>让我们从构建一个基本的 x86 系统开始。目前，您必须为要模拟的每个 ISA 分别编译 gem5。此外，如果使用 ruby-intro-chapter，您必须对每个缓存一致性协议进行单独的编译。</p>
<p>为了构建 gem5，我们将使用 SCons。SCons 使用 SConstruct 文件 ( <code>gem5/SConstruct</code>) 设置多个变量，然后使用每个子目录中的 SConscript 文件查找和编译所有 gem5 源代码。</p>
<p>SCons在第一次执行时会自动创建一个<code>gem5/build</code>目录。在此目录中，您将找到由 SCons、编译器等生成的文件。用于编译 gem5 的每组选项（ISA 和缓存一致性协议）都有一个单独的目录。</p>
<p>目录中有许多默认编译选项<code>build_opts</code> 。这些文件指定最初构建 gem5 时传递给 SCons 的参数。我们将使用 X86 默认值并指定我们要编译所有 CPU 模型。您可以查看文件 <code>build_opts/X86</code>以查看 SCons 选项的默认值。您还可以在命令行上指定这些选项以覆盖任何默认值。</p>
<pre><code class="language-bash">python3 `which scons` build/X86/gem5.opt -j9
</code></pre>
<blockquote>
<p><strong>gem5 二进制类型</strong></p>
<p>gem5 中的 SCons 脚本目前有 5 种不同的二进制文件，您可以为 gem5 构建：debug、opt、fast、prof 和 perf。这些名称大多是不言自明的，但在下面进行了详细说明。</p>
<ul>
<li>
<p>debug</p>
<p>没有优化和调试符号构建。如果您需要查看的变量在 gem5 的 opt 版本中进行了优化，则此二进制文件在使用调试器进行调试时非常有用。与其他二进制文件相比，使用 debug 运行速度较慢。</p>
</li>
<li>
<p>opt</p>
<p>这个二进制文件是使用大多数优化（例如，-O3）构建的，但包含调试符号。这个二进制文件比调试快得多，但仍然包含足够的调试信息来调试大多数问题。</p>
</li>
<li>
<p>fast</p>
<p>构建了所有优化（包括支持平台上的链接时优化）并且没有调试符号。此外，任何断言都被删除，但仍包括恐慌和致命。fast 是性能最高的二进制文件，比 opt 小得多。但是，仅当您认为您的代码不太可能存在重大错误时，才适合使用 fast。</p>
</li>
<li>
<p>prof and perf</p>
<p>这两个二进制文件是为分析 gem5 而构建的。prof 包括 GNU 分析器 (gprof) 的分析信息，perf 包括 Google 性能工具 (gperftools) 的分析信息。</p>
</li>
</ul>
<p>传递给 SCons 的主要参数是您想要构建的内容， <code>build/X86/gem5.opt</code>. 在这种情况下，我们正在构建 gem5.opt（带有调试符号的优化二进制文件）。我们想在 build/X86 目录下构建 gem5。由于此目录当前不存在，SCons 将查找<code>build_opts</code>X86 的默认参数。（注意：我在这里使用 -j9 在我机器上的 8 个内核中的 9 个上执行构建。您应该为您的机器选择一个合适的数量，通常是内核数+1。）</p>
</blockquote>
<p>输出应如下所示：</p>
<pre><code class="language-bash">Checking for C header file Python.h... yes
Checking for C library pthread... yes
Checking for C library dl... yes
Checking for C library util... yes
Checking for C library m... yes
Checking for C library python2.7... yes
Checking for accept(0,0,0) in C++ library None... yes
Checking for zlibVersion() in C++ library z... yes
Checking for GOOGLE_PROTOBUF_VERIFY_VERSION in C++ library protobuf... yes
Checking for clock_nanosleep(0,0,NULL,NULL) in C library None... yes
Checking for timer_create(CLOCK_MONOTONIC, NULL, NULL) in C library None... no
Checking for timer_create(CLOCK_MONOTONIC, NULL, NULL) in C library rt... yes
Checking for C library tcmalloc... yes
Checking for backtrace_symbols_fd((void*)0, 0, 0) in C library None... yes
Checking for C header file fenv.h... yes
Checking for C header file linux/kvm.h... yes
Checking size of struct kvm_xsave ... yes
Checking for member exclude_host in struct perf_event_attr...yes
Building in /local.chinook/gem5/gem5-tutorial/gem5/build/X86
Variables file /local.chinook/gem5/gem5-tutorial/gem5/build/variables/X86 not found,
  using defaults in /local.chinook/gem5/gem5-tutorial/gem5/build_opts/X86
scons: done reading SConscript files.
scons: Building targets ...
 [ISA DESC] X86/arch/x86/isa/main.isa -&gt; generated/inc.d
 [NEW DEPS] X86/arch/x86/generated/inc.d -&gt; x86-deps
 [ENVIRONS] x86-deps -&gt; x86-environs
 [     CXX] X86/sim/main.cc -&gt; .o
 ....
 .... &lt;lots of output&gt;
 ....
 [   SHCXX] nomali/lib/mali_midgard.cc -&gt; .os
 [   SHCXX] nomali/lib/mali_t6xx.cc -&gt; .os
 [   SHCXX] nomali/lib/mali_t7xx.cc -&gt; .os
 [      AR]  -&gt; drampower/libdrampower.a
 [   SHCXX] nomali/lib/addrspace.cc -&gt; .os
 [   SHCXX] nomali/lib/mmu.cc -&gt; .os
 [  RANLIB]  -&gt; drampower/libdrampower.a
 [   SHCXX] nomali/lib/nomali_api.cc -&gt; .os
 [      AR]  -&gt; nomali/libnomali.a
 [  RANLIB]  -&gt; nomali/libnomali.a
 [     CXX] X86/base/date.cc -&gt; .o
 [    LINK]  -&gt; X86/gem5.opt
scons: done building targets.
</code></pre>
<p>编译完成后，您应该在<code>build/X86/gem5.opt</code>. 编译可能需要很长时间，通常需要 15 分钟或更长时间，尤其是在 AFS 或 NFS 等远程文件系统上进行编译时。</p>
<h2 id="常见错误"><a class="header" href="#常见错误">常见错误</a></h2>
<h3 id="错误的-gcc-版本"><a class="header" href="#错误的-gcc-版本">错误的 gcc 版本</a></h3>
<pre><code class="language-bash">Error: gcc version 5 or newer required.
       Installed version: 4.4.7
</code></pre>
<p>更新您的环境变量以指向正确的 gcc 版本，或安装更新版本的 gcc。请参阅构建要求部分。</p>
<h3 id="python-位于非默认位置"><a class="header" href="#python-位于非默认位置">Python 位于非默认位置</a></h3>
<p>如果您使用非默认版本的 Python（例如，当 2.5 是您的默认版本时使用 3.6 版本），则在使用 SCons 构建 gem5 时可能会出现问题。RHEL6 版本的 SCons 使用 Python 的硬编码位置，这会导致问题。在这种情况下，gem5 通常构建成功，但可能无法运行。以下是您在运行 gem5 时可能会看到的一个错误。</p>
<pre><code class="language-bash">Traceback (most recent call last):
  File &quot;........../gem5-stable/src/python/importer.py&quot;, line 93, in &lt;module&gt;
    sys.meta_path.append(importer)
TypeError: 'dict' object is not callable
</code></pre>
<p>要解决此问题，您可以通过运行<code>python3 </code>which scons<code> build/X86/gem5.opt</code>代替<code>scons build/X86/gem5.opt</code>.</p>
<h3 id="未安装-m4-宏处理器"><a class="header" href="#未安装-m4-宏处理器">未安装 M4 宏处理器</a></h3>
<p>如果未安装 M4 宏处理器，您将看到类似于以下内容的错误：</p>
<pre><code class="language-bash">...
Checking for member exclude_host in struct perf_event_attr...yes
Error: Can't find version of M4 macro processor.  Please install M4 and try again.
</code></pre>
<p>仅安装 M4 宏包可能无法解决此问题。您可能还需要安装所有<code>autoconf</code>工具。在 Ubuntu 上，您可以使用以下命令。</p>
<pre><code class="language-bash">sudo apt-get install automake
</code></pre>
<h3 id="protobuf-3123-问题"><a class="header" href="#protobuf-3123-问题">Protobuf 3.12.3 问题</a></h3>
<p>使用 protobuf 编译 gem5 可能会导致以下错误，</p>
<pre><code class="language-bash">In file included from build/X86/cpu/trace/trace_cpu.hh:53,
                 from build/X86/cpu/trace/trace_cpu.cc:38:
build/X86/proto/inst_dep_record.pb.h:49:51: error: 'AuxiliaryParseTableField' in namespace 'google::protobuf::internal' does not name a type; did you mean 'AuxillaryParseTableField'?
   49 |   static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
</code></pre>
<p>这里讨论了问题的根本原因：[https://gem5.atlassian.net/browse/GEM5-1032]。</p>
<p>要解决此问题，您可能需要更新 ProtocolBuffer 的版本，</p>
<pre><code class="language-bash">sudo apt update
sudo apt install libprotobuf-dev protobuf-compiler libgoogle-perftools-dev
</code></pre>
<p>之后，您可能需要<strong>在</strong>重新编译 gem5<strong>之前</strong>清理 gem5 构建文件夹，</p>
<pre><code class="language-bash">python3 `which scons` --clean --no-cache        # cleaning the build folder
python3 `which scons` build/X86/gem5.opt -j 9   # re-compiling gem5
</code></pre>
<p>如果问题仍然存在，您可能需要<strong>在</strong>再次编译 gem5<strong>之前</strong>完全删除 gem5 build 文件夹，</p>
<pre><code class="language-bash">rm -rf build/                                   # completely removing the gem5 build folder
python3 `which scons` build/X86/gem5.opt -j 9   # re-compiling gem5
</code></pre>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                            <a rel="prev" href="../part0_introduction.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                            <a rel="next" href="../part1/part1_1_building.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                    <a rel="prev" href="../part0_introduction.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                    <a rel="next" href="../part1/part1_1_building.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
            </nav>

        </div>

        <script type="text/javascript">
            window.playground_copyable = true;
        </script>
        <script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
        <script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
        <script src="../book.js" type="text/javascript" charset="utf-8"></script>

        <!-- Custom JS scripts -->
    </body>
</html>
